split下标越界[number: 0]

来源:百度知道 编辑:UC知道 时间:2024/06/06 19:04:02
如果没有乡镇信息、则提取城市信息;如果有乡镇信息,则提取乡镇信息。

源代码如下:
<%dim iii1,temp1,temp2
iii1=split(request.form("City"),",")
temp1=iii1(0)
temp2=iii1(1)
if not isempty(split(request.form("Town"),",")) then
iii1=split(request.form("Town"),",")
temp1=iii1(0)
temp2=iii1(1)
end if
response.Write(temp1)
response.Write("<br>")
response.Write(temp2)
%>

程序只能完成乡镇信息的采集,无法完成当乡镇信息为空时采集城市信息。

运行结果为:
Microsoft VBScript 运行时错误 错误 '800a0009'

下标越界: '[number: 0]'

/Table_Server_Temp.asp,行 7

可能是你传进来的值split后只有一个索引,即是0。但是你取1的时候就会出错。

你可以先Response.write Ubound(iii1) 看一下他的下标到底有多大。如果小于1肯定是你那里出错了。